unit UInsertGridRow;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes,
  System.Variants,
  FMX.Grid;
procedure InsertRow(strigrid: TStringGrid; StartRow: Integer; cell0: String;
  cell1: String; cell2: String; cell3: String; cell4: String; cell5: String);
  procedure InsertInstruction(strigrid: TStringGrid; StartRow: Integer; cell0: String;
  cell1: String; cell2: String; cell3: String; cell4: String; cell5: String);

implementation

procedure InsertRow(strigrid: TStringGrid; StartRow: Integer; cell0: String;
  cell1: String; cell2: String; cell3: String; cell4: String; cell5: String);
var
  colindex, i, j: Integer;
begin
  strigrid.RowCount := strigrid.RowCount + 1;
  j := StartRow;

  for i := strigrid.RowCount downto StartRow do
  begin
    for colindex := 1 to strigrid.ColumnCount - 1 do
    begin
      strigrid.cells[colindex, i] := strigrid.cells[colindex, i - 1];
    end;
  end;
  for i := 0 to strigrid.RowCount - 1 do
  begin
    strigrid.cells[0, i] := (i + 1).toString();
  end;

  strigrid.cells[1, strigrid.Selected] := cell1;
  strigrid.cells[2, strigrid.Selected] := cell2;
  strigrid.cells[3, strigrid.Selected] := cell3;
  strigrid.cells[4, strigrid.Selected] := cell4;
  strigrid.cells[5, strigrid.Selected] := cell5;
end;

procedure InsertInstruction(strigrid: TStringGrid; StartRow: Integer; cell0: String;
  cell1: String; cell2: String; cell3: String; cell4: String; cell5: String);
var
  colindex, i, j: Integer;
begin
  strigrid.RowCount := strigrid.RowCount + 1;
  j := StartRow;

  for i := strigrid.RowCount+1 downto StartRow do
  begin
    for colindex := 1 to strigrid.ColumnCount - 1 do
    begin
      strigrid.cells[colindex, i] := strigrid.cells[colindex, i - 1];
    end;
  end;
  for i := 0 to strigrid.RowCount - 1 do
  begin
    strigrid.cells[0, i] := (i + 1).toString();
  end;

  strigrid.cells[1, strigrid.Selected+1] := cell1;
  strigrid.cells[2, strigrid.Selected+1] := cell2;
  strigrid.cells[3, strigrid.Selected+1] := cell3;
  strigrid.cells[4, strigrid.Selected+1] := cell4;
  strigrid.cells[5, strigrid.Selected+1] := cell5;
end;

end.
